import Vue from 'vue'
import Vuex from 'vuex'
import user from './user/index'
import createPersistedState from "vuex-persistedstate"
Vue.use(Vuex)
const createReverseWord = createPersistedState({
  key: 'reverseWrod',
  storage: window.localStorage,
  reducer: (state) => ({
    sentenceCurrent: state.sentenceCurrent,
    ModelXie: state.ModelXie,
    reverseStatus: state.reverseStatus,
    sentenceList: state.sentenceList,
  })
})
export default new Vuex.Store({
  state:{
    sentenceCurrent: {},
    ModelXie: {},
    reverseStatus: {},
    sentenceList: {
      list: [],
      test: {}
    },
    grammarExplainVisible: false,
    translateModalVisible: {
      visible: false,
    },
  },
  modules: {
    user
  },
  mutations:{
    setReverseStatus(state, params) {
      state.reverseStatus = params || {}
    },
    setTranslateModal(state, data) {
      state.translateModalVisible = data
    },
    setSentenceList(state, params) {
      state.sentenceList = params || {}
    },
    setGrammarExplain(state, visible) {
      state.grammarExplainVisible = visible
    },
    setSentenceCurrent(state, params) {
      state.sentenceCurrent = params || {}
    },
    setModelXie(state, params) {
      state.ModelXie = params || {}
    },
  },
  plugins:[createReverseWord]
})

